<?php
namespace app\admin\controller;
use app\common\model\Config;
use app\common\model\Manager as ManagerModel;
use app\common\model\ManagerGongzi as ManagerGongziModel;
use app\common\model\ManagerStudent;
use app\common\model\StudentKaoqin;
use app\common\model\ManagerGongziKouchu;

class Managergongzi extends Base
{
    public function __construct () {
        parent::__construct();
    }
    /*
     列表
     */
    public function list(){
        $input = input('get.');
        $where = [];
        $page = max(input('page'),1);
        $size = 20;
        if($input['mid']){
            $where['mid'] = $input['mid'];
        }
        if($input['time']){
            $where['time'] = $input['time'];
        }
        $gongziList = ManagerGongziModel::getPage($where,$page,$size);
        foreach($gongziList as $key => $gongzi){
            $w = array(
                'mgid' => $gongzi['id'],
                'time' => array('like',$gongzi['time'].'%')
            );
            $gongziList[$key]['kouchu']= ManagerGongziKouchu::getSum($w,'money');
        }
        $total = ManagerGongziModel::getCount($where);
        if(!$gongziList) {
            return returnJson(1,'');
        }
        return returnJson(0,'',[
            'list' => $gongziList,
            'size' => $size,
            'total' => $total
        ]);
    }

    public function update()
    {
        if(request()->isPost()){
            //工资信息
            $where = array(
                'id' => input('id')
            );
            ManagerGongziModel::gongziUpdate($where);
            return returnJson(1,'更新成功');
        }
        return returnJson(0,'更新失败');

    }

}
